/**
 * Copyright (c) 2020-2021 浦东大爷 All rights reserved.
 * 机会永远都是留给有准备的人
 */
package com.job.moudle2.task3;

import java.math.BigDecimal;

/**
 * @author: Scott.Yu
 * @date: 2020-11-12
 * @description:
 */
public class NetSetMeal extends SetMeal implements NetServiceImpl{
    private Double netData;

    public NetSetMeal() {
    }

    public NetSetMeal(Double netData, BigDecimal monthlyRates) {
        super(monthlyRates);
        this.netData = netData;
    }

    @Override
    public void show() {
        System.out.println("通话套餐信息：\n\t上网流量：" + netData +  "GB\t每月资费：" + getMonthlyRates());
    }

    public Double getNetData() {
        return netData;
    }

    public void setNetData(Double netData) {
        this.netData = netData;
    }

    /**
     * 模拟上网的时候的动作
     * 传入这个用户，以及上网产生的流量，扣除用户的流量，同时把统计加上去
     */
    @Override
    public void net(double netData, SIMCard simCard) {
        System.out.println("模拟上网冲浪的过程");
        simCard.setNetData(simCard.getNetData() - netData);
        System.out.println("上网使用流量" + netData + "GB,剩余免费流量：" + simCard.getNetData() + "GB");
        UserConsumption userConsumption = UserConsumption.getInstance();
        userConsumption.addNetData(netData);
    }
}
